package com.message.tcp.ip.socket.main;

import java.io.IOException;
import java.net.UnknownHostException;

import org.jpos.iso.ISOException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.message.tcp.ip.socket.builder.ReqMessageBuilder;
import com.message.tcp.ip.socket.client.MessageClient;

public class Main {
	/**
	 * @param args
	 * @throws ISOException 
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	public static void main(String[] args) throws ISOException, UnknownHostException, IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		ReqMessageBuilder binqReqMessageBuilder = (ReqMessageBuilder) context.getBean("echoReqMessageBuilder");
		MessageClient client = (MessageClient) context.getBean("messageClient");
		byte[] data = binqReqMessageBuilder.buildReqMessage();
		System.out.println(new String(data));
		client.runEchoClient(data);
	}

}
